<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The DOMXPath class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="domtext.splittext.html">« DOMText::splitText</a></li>
      <li style="float: right;"><a href="domxpath.construct.html">DOMXPath::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.dom.html">DOM</a></li>
    <li>The DOMXPath class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.domxpath" class="reference">
 <h1 class="title">The DOMXPath class</h1>
 
 
 <div class="partintro"><p class="verinfo">(PHP 5, PHP 7, PHP 8)</p>
 

  <div class="section" id="domxpath.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    Supports XPath 1.0
   </p>
  </div>

 
  <div class="section" id="domxpath.synopsis">
   <h2 class="title">类摘要</h2>
 

   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">DOMXPath</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">readonly</span>
     <span class="type"><a href="class.domdocument.html" class="type DOMDocument">DOMDocument</a></span>
      <var class="varname"><a href="class.domxpath.html#domxpath.props.document">$<var class="varname">document</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">bool</span>
      <var class="varname"><a href="class.domxpath.html#domxpath.props.registernodenamespaces">$<var class="varname">registerNodeNamespaces</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="domxpath.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><a href="class.domdocument.html" class="type DOMDocument">DOMDocument</a></span> <code class="parameter">$document</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$registerNodeNS</code><span class="initializer"> = <strong><code>true</code></strong></span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="domxpath.evaluate.html" class="methodname">evaluate</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$expression</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span><span class="type"></span></span> <code class="parameter">$contextNode</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$registerNodeNS</code><span class="initializer"> = <strong><code>true</code></strong></span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="domxpath.query.html" class="methodname">query</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$expression</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span><span class="type"></span></span> <code class="parameter">$contextNode</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$registerNodeNS</code><span class="initializer"> = <strong><code>true</code></strong></span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="domxpath.registernamespace.html" class="methodname">registerNamespace</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$prefix</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$namespace</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="domxpath.registerphpfunctions.html" class="methodname">registerPhpFunctions</a></span>(<span class="methodparam"><span class="type"><span class="type">string</span>|<span class="type">array</span>|<span class="type">null</span></span> <code class="parameter">$restrict</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type void">void</span></span></div>

   }</div>

 
  </div>
 


  <div class="section" id="domxpath.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="domxpath.props.document"><var class="varname">document</var></dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="domxpath.props.registernodenamespaces"><var class="varname">registerNodeNamespaces</var></dt>

     <dd>

      <p class="para">When set to <strong><code>true</code></strong>, namespaces in the node are registered.</p>
     </dd>

    
   </dl>

  </div>


  <div class="section">
   <h2 class="title">更新日志</h2>
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        The <var class="varname">registerNodeNamespaces</var> property has been added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </div>
  



 
 </div>
 
 

























 
<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="domxpath.construct.html">DOMXPath::__construct</a> — Creates a new DOMXPath object</li><li><a href="domxpath.evaluate.html">DOMXPath::evaluate</a> — Evaluates the given XPath expression and returns a typed result if possible</li><li><a href="domxpath.query.html">DOMXPath::query</a> — Evaluates the given XPath expression</li><li><a href="domxpath.registernamespace.html">DOMXPath::registerNamespace</a> — Registers the namespace with the DOMXPath object</li><li><a href="domxpath.registerphpfunctions.html">DOMXPath::registerPhpFunctions</a> — Register PHP functions as XPath functions</li></ul>
</div>
</div></div></body></html>